home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DESQVIEW.SWG / 0001_DESQVIEW.PAS.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  5KB  |  238 lines

  1. { Does anyone know the routine For making a Program DV aware, and if it
  2.  finds it, can you get it to make calls to it instead of Dos?
  3. }
  4. Here is a desqview Unit I have used in the past.
  5.  
  6. Unit DESQVIEW ;
  7.  
  8. {$O+,F+}
  9.  
  10. Interface
  11.  
  12. Uses Dos ;
  13.  
  14. Var
  15.   DV_ACTIVE    : Boolean ;          { True if running under DESQview     }
  16.   Win_ACTIVE   : Boolean ;          { True if Windows 3.x Enhanced Mode  }
  17.   DV_VERSION   : Word ;             { desqVIEW version number            }
  18.   DV_VSEG      : Word ;
  19.   DV_VMODE     : Byte Absolute $0040:$0049 ;
  20.   DV_VWIDTH    : Byte ;
  21.   DV_VROWS     : Byte ;
  22.   DV_VofS      : Word ;
  23.  
  24.  
  25. Procedure DV_RQM   ;                { Give up the rest of our timeslice  }
  26. Procedure DV_begin_CRITICAL ;       { Turn Task Switching off.           }
  27. Procedure DV_end_CRITICAL ;         { Turn switching back on.            }
  28. Procedure DV_VIDEO_BUFFER ;         { Set Global Video Variables         }
  29. Function  DV_Window_NUMBER : Byte ; { Returns Window Number              }
  30. Procedure DV_COMMON_MEMorY(Var AVAIL, LARGEST, toTAL: Word) ;
  31. Procedure DV_CONV_MEMorY  (Var AVAIL, LARGEST, toTAL: Word) ;
  32. Procedure DV_EMS_MEMorY   (Var AVAIL, LARGEST, toTAL: Word) ;
  33. Procedure DV_FASTWrite    (X,Y: Word; STR: String; FG,BG: Word) ;
  34.  
  35. Implementation
  36.  
  37. Var
  38.   REG     : Registers ;
  39.  
  40. Procedure DV_RQM ;
  41.  
  42. begin
  43.   if DV_ACTIVE then begin
  44.     Asm
  45.       mov  ax, 1000h
  46.       int  15h
  47.     end ;
  48.   end else begin
  49.     if Win_ACTIVE then begin
  50.       Asm
  51.         mov  ax, 1680h
  52.         int  2fh
  53.       end ;
  54.     end ;
  55.   end ;
  56. end { dv_rqm };
  57.  
  58. Procedure DV_begin_CRITICAL ;
  59.  
  60. begin
  61.   if DV_ACTIVE then begin
  62.     Asm
  63.       mov   ax, $101b
  64.       int   15h
  65.     end ;
  66.   end else begin
  67.     if Win_ACTIVE then begin
  68.       Asm
  69.         mov  ax, 1681h
  70.         int  2fh
  71.       end ;
  72.     end ;
  73.   end ;
  74. end ; { dv_begin_critical }
  75.  
  76. Procedure DV_end_CRITICAL ;
  77.  
  78. begin
  79.   if DV_ACTIVE then begin
  80.     Asm
  81.       mov   ax, $101c
  82.       int   15h
  83.     end ;
  84.   end else begin
  85.     if Win_ACTIVE then begin
  86.       Asm
  87.         mov  ax, $1682
  88.         int  2fh
  89.       end ;
  90.     end ;
  91.   end ;
  92. end ; { dv_end_critical }
  93.  
  94. Procedure DV_VIDEO_BUFFER ;
  95.  
  96. begin
  97.   if DV_ACTIVE then begin
  98.     Asm
  99.       mov  ax, $2b02
  100.       mov  bx, $4445  ; { DE }
  101.       mov  dx, $5351  ; { SQ }
  102.       int  21h
  103.       mov  DV_VSEG, dx
  104.       mov  DV_VWIDTH, bl
  105.       mov  DV_VROWS, bh
  106.       mov  DV_VofS, 0
  107.     end ;
  108.   end else begin
  109.     if (DV_VMODE = 7) then DV_VSEG := $b000 else DV_VSEG := $b800 ;
  110.     DV_VWIDTH := memw[$0040:$004a] ;
  111.     DV_VROWS  := 25 ;
  112.     DV_VofS   := memw[$0040:$004e] ;
  113.   end ;
  114. end ; { dv_video_buffer }
  115.  
  116. Function DV_Window_NUMBER ;
  117.  
  118. begin
  119.   if DV_ACTIVE then begin
  120.     Asm
  121.       mov   ax, $de07
  122.       int   15h
  123.       mov  @RESULT, al
  124.     end ;
  125.   end else begin
  126.     DV_Window_NUMBER := 0 ;
  127.   end ;
  128. end ;
  129.  
  130. Procedure DV_COMMON_MEMorY ;
  131.  
  132. begin
  133.   if DV_ACTIVE then begin
  134.     Asm
  135.       mov  ax, $de04
  136.       int  15h
  137.       les  di, AVAIL
  138.       mov  es:[di], bx
  139.       les  di, LARGEST
  140.       mov  es:[di], cx
  141.       les  di, toTAL
  142.       mov  es:[di], dx
  143.     end ;
  144.   end else begin
  145.     AVAIL := 0 ;
  146.     LARGEST := 0 ;
  147.     toTAL := 0 ;
  148.   end ;
  149. end ;
  150.  
  151. Procedure DV_CONV_MEMorY ;
  152.  
  153. begin
  154.   if DV_ACTIVE then begin
  155.     Asm
  156.       mov  ax, $de05
  157.       int  15h
  158.       les  di, AVAIL
  159.       mov  es:[di], bx
  160.       les  di, LARGEST
  161.       mov  es:[di], cx
  162.       les  di, toTAL
  163.       mov  es:[di], dx
  164.     end ;
  165.   end else begin
  166.     AVAIL := 0 ;
  167.     LARGEST := 0 ;
  168.     toTAL := 0 ;
  169.   end ;
  170. end ;
  171.  
  172. Procedure DV_EMS_MEMorY ;
  173.  
  174. begin
  175.   if DV_ACTIVE then begin
  176.     Asm
  177.       mov  ax, $de06
  178.       int  15h
  179.       les  di, AVAIL
  180.       mov  es:[di], bx
  181.       les  di, LARGEST
  182.       mov  es:[di], cx
  183.       les  di, toTAL
  184.       mov  es:[di], dx
  185.     end ;
  186.   end else begin
  187.     AVAIL := 0 ;
  188.     LARGEST := 0 ;
  189.     toTAL := 0 ;
  190.   end ;
  191. end ;
  192.  
  193. Procedure DV_FASTWrite ;
  194.  
  195. Var
  196.   I      : Word ;
  197.  
  198. begin
  199.   X := DV_VofS + ((Y-1) * DV_VWIDTH + (X-1)) * 2 ;
  200.   For I := 1 to length(STR) do begin
  201.     MEMW[DV_VSEG:X] := (((BG shl 4) + FG) shl 8) + ord(STR[I]) ;
  202.     X := X + 2 ;
  203.   end ;
  204. end ;
  205.  
  206. begin { main }
  207.   REG.AX := $2b01 ;
  208.   REG.CX := $4445 ;  { DE }
  209.   REG.DX := $5351 ;  { SQ }
  210.   intr($21,REG) ;
  211.  
  212.   Win_ACTIVE := False ;
  213.   DV_ACTIVE := (REG.AL <> $ff) ;
  214.  
  215.   DV_VERSION := 0 ;
  216.   if DV_ACTIVE then begin
  217.     DV_VERSION := REG.BX ;
  218.     REG.AX := $de0b ;
  219.     REG.BX := $0200 ;  { Minimum of Desqview 2.00 }
  220.     intr($15,REG) ;
  221.   end else begin
  222.     REG.AX := $1600 ;
  223.     intr($2f,REG) ;
  224.     Case REG.AL of
  225.       $00 : ; { An enhanced Windows API is not Running }
  226.       $80 : ; { An enhanced Windows API is not Running }
  227.       $01 : ; { Windows / 386 Version 2.x              }
  228.       $ff : ; { Windows / 386 Version 2.x              }
  229.       else begin
  230.         Win_ACTIVE := True ;
  231.         DV_VERSION := swap(REG.AX) ;
  232.       end ;
  233.     end ;
  234.   end ;
  235.  
  236.   DV_VIDEO_BUFFER ;
  237. end. { main }
  238.